package com.google.coffeeshop.gui.desktop.orderpayment;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

import com.google.coffeeshop.business.MaintenanceBusiness;
import com.google.coffeeshop.business.OrderBusiness;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class EmployeeChoosingFrame extends JFrame {
	private static final long serialVersionUID = 1L;
	private SeatBoardPanel parent;
	private SeatButton seatButton;
	private EmployeeChoosingPanel pnlEmployeeChoosing;
	
	public EmployeeChoosingFrame(SeatBoardPanel parent, SeatButton seatButton) {
		this.parent = parent;
		this.seatButton = seatButton;
		setTitle("Employee Choice");
		setSize(481, 434);
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
		getContentPane().setLayout(gridBagLayout);
		
		JLabel lblNewLabel = new JLabel("Choose a employee to serve this seat...");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.WEST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
		gbc_lblNewLabel.gridx = 0;
		gbc_lblNewLabel.gridy = 0;
		getContentPane().add(lblNewLabel, gbc_lblNewLabel);
		
		pnlEmployeeChoosing = new EmployeeChoosingPanel();
		GridBagConstraints gbc_pnlEmployeeChoosing = new GridBagConstraints();
		gbc_pnlEmployeeChoosing.insets = new Insets(0, 0, 5, 0);
		gbc_pnlEmployeeChoosing.fill = GridBagConstraints.BOTH;
		gbc_pnlEmployeeChoosing.gridx = 0;
		gbc_pnlEmployeeChoosing.gridy = 1;
		getContentPane().add(pnlEmployeeChoosing, gbc_pnlEmployeeChoosing);
		
		JButton btnOK = new JButton("OK");
		btnOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				disposeFrame();
				showSeatDetailFrame();
			}
		});
		GridBagConstraints gbc_btnOK = new GridBagConstraints();
		gbc_btnOK.fill = GridBagConstraints.HORIZONTAL;
		gbc_btnOK.gridx = 0;
		gbc_btnOK.gridy = 2;
		getContentPane().add(btnOK, gbc_btnOK);
		
	}
	
	private void disposeFrame() {
		this.dispose();
	}
	
	private void showSeatDetailFrame() {
		parent.showSeatDetailFrame(seatButton, pnlEmployeeChoosing.getChosenEmployeeId());
	}

}

